package com.itsu.mysql.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.itsu.interfaces.entity.Question;
import com.itsu.interfaces.service.QuestionService;
import com.itsu.mysql.mappers.QuestionMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class QuestionServiceImpl implements QuestionService {

    @Autowired
    QuestionMapper questionMapper;

    @Override
    public Question findByUserId(Integer userId) {
        return questionMapper.selectOne(Wrappers.lambdaQuery(Question.class).eq(Question::getUserId, userId));
    }

    @Override
    public void updateQuestions(Question question) {
        questionMapper.update(question, Wrappers.lambdaQuery(Question.class).eq(Question::getUserId, question.getUserId()));
    }
}
